package testDriver;

import java.util.List;

import hibernate.DTOStationList;
import hibernate.Location;
import hibernate.Station;


/*
 * station.stationsProches(distance)
 */

public class TestingJavaQuestion4 
{
	
	public static final int MAX_DISPLAY = 5;
	public static void main(String[] args) 
	{
		Station station = new Station();
		station.setId(1055);
		Location mylocation = station.getLocation();
		DTOStationList dtoStationList = station.stationsProches(1000);
		List<Station> list = dtoStationList.getStationList();
		int count = 0;
		if (list != null) {
			System.out.println("Station ayant le plus changé de définition:");
			for (Station s : list) {
				
				double lat = s.getLatitude();
				double lon = s.getLongitude();
				double distance = Math.pow(lat - mylocation.getLatitude(), 2) + Math.pow(lon - mylocation.getLongitude(), 2);
				distance = Math.sqrt(distance);
				System.out.println("*** Distance: " + distance + "***");
				System.out.println(s.toString());
				
				count ++;
				if (count == MAX_DISPLAY) break;				
			}
		}
	}
}
